# the minimum version of CMake.
cmake_minimum_required(VERSION 3.5.0)
project(embeddedbridge)

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})

if(DEFINED PACKAGE_FIND_FILE)
    include(${PACKAGE_FIND_FILE})
endif()

list(APPEND CMAKE_FIND_ROOT_PATH ${QT_PREFIX})
include_directories(${NATIVERENDER_ROOT_PATH}
                    ${NATIVERENDER_ROOT_PATH}/include)

find_package(QT NAMES Qt5 Qt6 REQUIRED COMPONENTS Core)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Gui Widgets)
file(GLOB source CONFIGURE_DEPENDS *.h *.cpp *.qrc)

add_library(embeddedbridge SHARED
    ./src/napi_util.cpp
    ./include/EmbeddedBridgeQtSide.h
    ./include/EmbeddedBridgeJsSide.h
    ./src/EmbeddedBridge.cpp
    ./src/EmbeddedBridgeQtSide.cpp
    ./src/EmbeddedBridgeJsSide.cpp
    ./include/FlutterEmbeddedQWidget.h
    ./src/FlutterEmbeddedQWidget.cpp
    ./src/EmbeddedQWidgetFactory.cpp
    ./src/Embeddedcomponent.cpp
    napi_init.cpp
    )
target_include_directories(embeddedbridge PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)

target_link_libraries(embeddedbridge PRIVATE
    libace_napi.z.so
    libace_ndk.z.so
    libuv.so
    libhilog_ndk.z.so
    Qt${QT_VERSION_MAJOR}::Core
    Qt${QT_VERSION_MAJOR}::Widgets )